# -*- coding:utf-8 -*-
# @FileName  :5.Edge无头浏览器.py
# @Time      :2024/8/15 下午1:38
# @Author    :鲁大师
import time
from selenium import webdriver
# 实现无可视化界面
from selenium.webdriver.edge.options import Options

# 实现规避检测
from selenium.webdriver import EdgeOptions

# 实现无可视化界面的操作
edge_options = Options()
edge_options.add_argument('--headless')
edge_options.add_argument('--disable-gpu')

# 实现规避检测
option=EdgeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])

bro = webdriver.Edge(options=edge_options)
bro.get('https://www.baidu.com')
print(bro.page_source)
time.sleep(2)
bro.quit()

if __name__ == "__main__":
    pass
